<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    var i = 10;



    function fn(){
        var i=10; //10

        return function(n){ //闭包
            console.log(n+(++i))
        }
    }

    var f=fn();/// i=10;
    // f = function(n){
//    console.log(n+(++i)) //i =10 ==>11 ==>12
//    }

    f(10); //10 + 11 ==> 21
    f(20); //20 + 12 ==> 32



    //i=10
//    f = function(n){
//    console.log(n+(++i)) //i =10
//    }
    fn()(10);  //21
    f = fn();
    f(10);

    fn()(20); //31
</script>
</body>
</html>